<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>closure</title>
    </head>
    <body>
        <script>
            Math.pow(4, 2);
            Math.pow(5, 2);

            function makePower(power) {
                return function (number) {
                    return Math.pow(number, power);
                };
            }

            // 求平方 定义一个n次方
            let power2 = makePower(2);
            let power3 = makePower(3);

            // 根据不同的n次方再传入数值,最后得到 4的2次方 和 4的3次方
            console.log(power2(4));
            console.log(power3(4));
        </script>
    </body>
</html>
